<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
<button class="btn">发送请求</button>

<script src="./utils.js"></script>
<script>

// 设置cookie数据
setCookie({
    key: 'user1',
    val: 'xiaocuo',
    path: '/',
    exp: 60*8
})

setCookie({
    key: 'user2',
    val: 'xiaohua',
    path: '/',
    exp: 60*8
})

// cookie的一个特征: cookie会随着http请求自动发送到服务端(在请求头)

let btn = document.querySelector('.btn')
btn.onclick = function (){
    ajax({
        type: 'get',
        url: 'http://localhost:8080/users/cookie'
    })
    .then((res)=>{
        console.log( res )
    })
}

</script>
</body>
</html>